<?php

namespace App\Http\Requests\System;

use App\Http\Requests\BaseRequest;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class Manager extends BaseRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'account' => [
                'required',
                Rule::unique('users')
                ->ignore(request()->id)
                ->whereNull('deleted_at')
            ],
            'name' => 'required',
            'type' => 'required',
            'contact' => 'required',
            'department_id' => 'required',
            'phone' => 'required',
            'description' => 'required',
        ];
    }

    public function messages(){
        return [
            'account.required' => '请输入用户账号',
            'account.unique' => '用户账号重复',
            'name.required' => '请输入用户名称',
            'type.required' => '请输入联系对象类型',
            'contact.required' => '请输入联系对象',
            'department_id.required' => '请输入部门',
            'phone.required' => '请输入用户电话',
            'description.required' => '请输入用户说明',
        ];
    }
}
